package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.entity.dto.Account;
import org.example.entity.dto.RsAccountForum;
import org.example.entity.vo.response.AccountExtendVO;
import org.example.mapper.AccountMapper;
import org.example.mapper.CustomizeMapper;
import org.example.mapper.RsAccountForumMapper;
import org.example.service.RsAccountForumService;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class RsAccountForumServiceImpl extends ServiceImpl<RsAccountForumMapper, RsAccountForum> implements RsAccountForumService {
    @Resource
    AccountMapper accountMapper;
    @Resource
    CustomizeMapper customizeMapper;

    public AccountExtendVO getForumLeaderInfo(Integer forumID) {
        Integer leaderID = customizeMapper.getForumLeaderIDByForumID(forumID);
        if (leaderID==null) {
            return null;
        }
        Account account = accountMapper.selectById(leaderID);
        Map<String, Object> map = customizeMapper.getAccountExtendByUserID(leaderID);
        AccountExtendVO accountExtendVO = new AccountExtendVO();
        accountExtendVO.setId(leaderID);
        accountExtendVO.setIcon((String) map.get("icon"));
        accountExtendVO.setUserName(account.getUsername());
        accountExtendVO.setADescribe((String) map.get("a_describe"));
        return accountExtendVO;
    }
}
